import Mock from "mockjs";

// 定义数据类型
let { data } = Mock.mock({
  // 20条数据
  "data|3-10": [
    {
      "_id|+1": 1,
      title: "@ctitle(6)",
      imgUrl: "@Image('100x100','@color','小甜甜')",
      "score|5-10.1": 5,
      "wishNum|100-100000": 100,
    },
  ],
});

export default {
  // 返回值可以是数组形式
  "GET /api/rated/list": {
    status: 0,
    result: data,
  },

  "POST /api/rated/remove": (req: any, res: any) => {
    const { id } = req.body;

    if (id) {
      data = data.filter((item: any) => item._id !== +id);
      res.json({
        status: 0,
        msg: "删除成功",
      });
    } else {
      res.json({
        status: 1001,
        msg: "参数错误",
      });
    }
  },

  // 返回值也可以是对象形式
  "GET /api/users/1": { id: 1, name: "foo" },
};
